package DMSXL._2023Before.String_;

/*public class strStr_ {
    public static void main(String[] args) {
        String haystack =  "mississippi";
        String needle = "issippi";
        Solution solution = new Solution();
        System.out.println(solution.strStr(haystack,needle));
    }
}
class Solution {
    public int strStr(String haystack, String needle) {

        if(haystack.length() < needle.length())
            return -1;
        char[] hay = haystack.toCharArray();
        char[] son = needle.toCharArray();

        for (int i = 0; i <= haystack.length() - needle.length() ; i++) {
            if(hay[i] == son[0])//代表第一个字符匹配，此时进入查找接下来是否是该字符
            {
                for (int j = 0; j < son.length; j++) {
                    if(hay[i + j] != son[j])
                        break;
                    else {
                        if(j == son.length - 1)
                            return i;
                    }
                }
            }
        }
        return -1;
    }
}*/
